﻿using CodeGenerator.Console.CodeGenBLService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeGenerator.Console
{
    public class DisplayClassAction : IDisplayableAction
    {
        
        public void Display(int id)
        {
            ProjectPkDto dto = new ProjectPkDto();
            dto.ProjectId = GetId();

            CodeGenBLClient client = new CodeGenBLClient();
            List<ClassHeaderDto> result = client.GetClassNameByProjectId(dto).Data;

            System.Console.WriteLine("");
            foreach (ClassHeaderDto c in result)
            {
                System.Console.WriteLine(c.Id.ToString() + " : " + c.name);
            }
            System.Console.WriteLine("");
        }

        private int GetId()
        {
            System.Console.Write("Enter Project ID : ");
            try
            {
                var input = Convert.ToInt32(System.Console.ReadLine());
                return input;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex);
                return -1;
            }
        }
    }
}
